<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title></title>
    <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css" media="all">
</head>
<style type="text/css">
    .layui-form {
        margin: 15px 0;
    }

    .layui-form-label {
        width: 100px;
        text-align: left;
    }

    .layui-tab {
        border: 1px solid #00F7DE;
    }

    .tab-ul {
        width: 100%;
    }

    .tab-ul li dd {
        /*width: 13.28%;*/
        height: 60px;
        float: left;
        flex: 1;
        /*border: 1px solid #007DDB;*/
    ;
    }

    .tab-ul-title {
        height: 40px;
        width: 100%;
        text-align: center;
        line-height: 40px;
        font-size: 16px;
        font-weight: bold;
        /*border: 1px solid #007DDB;*/
        border-bottom: 0
    }

    .week-title td {
        text-align: center;
    }

    .layui-table td {
        padding: 0px!important;
    }

    input[type='text'] {
        /*width: 80px;*/
        margin: 5px auto;
    }

    .ri,
    .ri-w {
        padding: 19px 20px;
        /*width: 100%;
        height: 100%;	*/
    }

    .ri-w {
        color: #CCCCCC;
    }

    .batch {
        float: right;
        margin: 0px 25px 0 10px;
    }

    .emptys {
        color: #00F7DE;
    }

    #ceshi {
        /*width: 100%;
        height: 100%;*/
        display: none;
    }

    .bj {
        background: #00F7DE;
    }

    .tas {
        overflow: hidden
    }

    .admins {
        margin-left: 0;
        text-align: center;
    }

    .layui-table tbody tr:hover {
        background-color: ' ' !important;
    }
    .titl{
        padding: 5px 15px;
        width: 100%;
        text-align: center;
        font-size: 16px;
    }
    .light_star{
        background:#00b7ee;
    }
    .new_star{
        background:greenyellow;
    }
    .light_star:after{
        content:'*';
        width: 0;
        height: 0;
        color: red;

    }
    .new_star:after{
        content:'*';
        width: 0;
        height: 0;
        color: deepskyblue;

    }
    .personlog{
        height: auto;
        text-align: left;
    }
    .delPersonlog{
        margin-left: 8px;
        margin-right: 16px;
        color:red
    }
</style>

<body>

<div class="layui-container">

    <form class="layui-form" action="">
        <input type="hidden" name="goods_id" id="goods_id" value="{$goods.goods_id}" />
        <ul class="">

            <li>
                <div class="layui-form-item">
                    <label class="layui-form-label" style="margin:5px 0">商品售卖时间:</label>
                    <div class="layui-input-inline layui-col-md5">
                        <input type="text" id="starttime" name="starttime" value="{$starttime}" placeholder="开始时间" class="layui-input" readonly />
                    </div>
                    <div style=" text-align: center;line-height: 38px;width: 25px;height: 38px;float: left;margin:5px 10px 5px 0;">至</div>
                    <div class="layui-input-inline layui-col-md6">
                        <input type="text" id="endtime" name="endtime" value="{$endtime}" placeholder="结束时间" class="layui-input" readonly/>
                    </div>
                    <div class="layui-input-inline layui-col-md6"style="width:30%;">
                        <!--<input type="button" id="button" style="margin: 5px auto;" value="确认" placeholder="结束时间" class="layui-btn" />-->
                        <input type="button" style="margin: 5px auto;" value="刷新" onClick="window.location.reload();" class="layui-btn" />
                        <input type="button" style="margin: 5px auto;" value="返回上一页" onClick="javascript :history.back(-1);" class="layui-btn" />
                        <!--<a href="{:url('admin/goods/showspecs')}?id={$_GET['id']}" class="a_menu">-->
                            <!--<input type="button" style="margin: 5px auto;" value="查看套餐" onClick="" placeholder="结束时间" class="layui-btn" />-->
                        <!--</a>-->
                    </div>
                </div>

            </li>

            <li>
                <div class="layui-tab" lay-filter="test1">
                    <div id="tab-title">
                        <ul class="layui-tab-title Spec">

                        </ul>
                    </div>

                    <div class="layui-tab-content content" style="overflow: auto;">

                    </div>

                </div>

            </li>

        </ul>

    </form>

    <!--批量添加的弹层-->
    <div id="ceshi">
        <form class="layui-form" action="" method="post" name="ceshi">
            <input type="hidden" id="specs_ids" value="" />
            <ul>
                <li class="time-content">
                    <div class="layui-form-item shijian" style="margin: 0;">
                        <label class="layui-form-label">选择时间段:<br><span style="font-size: 12px;">(时间为当地时间)</span></label>
                        <div class="layui-input-inline layui-col-md5">
                            <input type="text" id="" name="t-starttime" value="" placeholder="开始时间" class="layui-input x" autocomplete="off" />
                        </div>
                        <div style=" text-align: center;line-height: 38px;width: 25px;height: 38px;float: left;margin-right: 10px;">至</div>
                        <div class="layui-input-inline layui-col-md6">
                            <input type="text" id="" name="t-endtime" value="" placeholder="结束时间" class="layui-input x" autocomplete="off" />
                        </div>
                    </div>

                </li>
                <li>

                    <div class="layui-form-item" style="margin: 0;">
                        <label class="layui-form-label">&nbsp;</label>
                        <div class="layui-input-inline layui-col-md12">
                            在以上时间段中选择：
                        </div>
                    </div>

                </li>
                <li>
                    <div class="layui-form-item " id="selectTimeForm">


                    </div>
                    <div class="layui-form-item " id="moreTimeForm" style="display: none;">
                        <label class="layui-form-label">&nbsp;</label>
                        <div class="layui-input-block layui-col-xs8" style="margin: 0;">
                            <input style="width:160px;" type="text" name="moreTime" value="" placeholder="开始时间" class="layui-input layui-input-inline x" />
                            <a class="layui-btn layui-btn-sm layui-btn-normal addMoreTime" style="margin-top:8px;">添加</a>
                        </div>
                        <div class="layui-input-block layui-col-xs8" style="margin-left:130px;background: #eee;width:620px;">
                            <div style="width:620px;min-height:50px;" id="moreTimeArr">
                            </div>
                        </div>
                    </div>
                </li>
                <li>
                    <div class="layui-input-block layui-col-xs10" style="margin-left:130px;">
                        <table class="layui-table">
                            <thead>
                            <tr>
                                <th>名称</th>
                                <th>价格</th>
                                <th>数量</th>
                                <th>最低下单数</th>
                                <th>最小增长数</th>
                                {notempty name='$standard_id'}
                                <th>用车类型</th>
                                {/notempty}
                            </tr>
                            </thead>
                            <tbody class="batch_person">
                            <!--<tr>
                                <th>成人价格</th>
                                <th><input type="number" name="" id="" class="layui-input" placeholder="成人价格" value="" /></th>
                                <th><input type="number" name="" id="" class="layui-input" placeholder="数量" value="" /></th>
                                <th><input type="number" name="" id="" class="layui-input" placeholder="最低下单" value="" /></th>
                            </tr>
                            <tr>
                                <th>儿童价格</th>
                                <th><input type="number" name="" id="" class="layui-input" placeholder="儿童价格" value="" /></th>
                                <th><input type="number" name="" id="" class="layui-input" placeholder="数量" value="" /></th>
                                <th><input type="number" name="" id="" class="layui-input" placeholder="最低下单" value="" /></th>
                            </tr>-->
                            </tbody>

                        </table>
                    </div>
                </li>

            </ul>
        </form>
    </div>
</div>
</body>
<script src="__PUBLIC__/layui/layui.js"></script>
<script src="__PUBLIC__/jquery/jquery.min.js"></script>
<script type="text/javascript">
    var moreTimeList = [];
    layui.use(['layer', 'element', 'form', 'laydate'], function() {
        //http://k.com/index.php
        //规格获取
        var specsurl = '/admin/goods/werk'
        //人群获取
        var posurl = '/admin/goods/pos'
        //提交选项卡
        var editurl = '/admin/goods/addperson'
        //初始化页面未提交 点击确认按钮设置为1
        var is_update = 0;
        //获取数据
        var id = {$goods.goods_id};
        var logid = 0;
        var starttime = "{$starttime}";
        var endtime = "{$endtime}";
        var personprice = {};
        var personlog = {};

        var list = {$data};
        var layer = layui.layer,
            element = layui.element,
            form = layui.form,
            laydate = layui.laydate;

        //批量初始化时间控件
        $('.x').each(function() {
            laydate.render({
                elem: this //指定元素
            });
        });

        function getPersonPrice(){
            $.ajax({
                url:"/admin/goods/personprice",
                type:"POST",
                dataType:'json',
                async:false,
                data:{id:id,sdate:starttime,edate:endtime},
                success:function (data) {
                    personprice = data.data;
                }
            })
        }

        function getPersondayLog(){
            $.ajax({
                url:"/admin/goods/getPersondayLog",
                type:'POST',
                dataType:'json',
                async:false,
                data:{goods_id:id},
                success:function(data){
                    personlog = data.data;
                }
            })
        }
        getPersonPrice();
        getPersondayLog();
        //点击加号添加时间框
        $(document).on('click', '.addtime', function() {
            var str = '<div class="layui-form-item shijian" style="margin: 0;">';
            str += '<label class="layui-form-label">&nbsp;</label>' +
                '<div class="layui-input-inline layui-col-md5">' +
                '<input type="text" id="" name="t—starttime" value="" placeholder="开始时间" class="layui-input x" />' +
                '</div>' +
                '<div style=" text-align: center;line-height: 38px;width: 25px;height: 38px;float: left;margin-right: 10px;">至</div>' +
                '<div class="layui-input-inline layui-col-md6">' +
                '<input type="text" id="" name="t—endtime" value="" placeholder="结束时间" class="layui-input x" />' +
                '</div>' +
                '<div class="layui-col-md1" ><i class="layui-icon layui-icon-delete deltime" style="font-size: 40px;"></i></div>' +
                '</div>';
            $('.time-content').append(str);
            //重新渲染时间控件
            $('.x').each(function() {
                laydate.render({
                    elem: this //指定元素
                });
            });
        })
        $(document).on('click', '.deltime', function() {

            $(this).parent().parent().remove()

        })

        $(document).on('click', '.emptys', function() {

            var specs = $(this).attr('date-pid')
            var tr = $('#yue' + specs + ' .tabto ._person tr');
            layer.msg('取消后无法恢复 请谨慎操作', {
                time: 0 //不自动关闭
                ,
                btn: ['确定', '取消'],
                yes: function(index) {
                    $.each($('.ri'),function(i,v){
                        $($('.ri')[i]).removeClass('new_star');
                    })
                    for(var i = 0; i < tr.length; i++) {
                        var datass = {};
                        $(tr[i]).find("input[name=person_name]").val(null);
                        $(tr[i]).find("input[name=person_price]").val(null);
                        $(tr[i]).find("input[name=person_num]").val(null);
                        $(tr[i]).find("input[name=minorder_num]").val(null);
                        $(tr[i]).find("input[name=inc_order_num]").val(null);
                        {notempty name='$standard_id'}
                        $(tr[i]).find("select[name=carType]").val("");
                        {/notempty}
                    }
                    layer.close(index);
                    layer.msg('清空成功');
                }
            });

        })

        //点击日期类型 切换tab
        function changeTimeType(value){
            if(value==1){
                $("#single").show();
                $("#week").hide();
                $("#moreTimeForm").show();
            }else if(value==2){
                $("#single").hide();
                $("#week").show();
                $("#moreTimeForm").show();
            }else if(value==3){
                $("#single").hide();
                $("#week").hide();
                $("#moreTimeForm").show();
            }else{
                $("#single").hide();
                $("#week").hide();
                $("#moreTimeForm").hide();
            }
        }
        //表单提交
        form.on('submit(admin)', function(data) {
            var specs = $(this).attr('date-bt');
            data = [];
            var tr = $('#yue' + specs + ' .tabto ._person tr');
            var goods = $('input[name="goods_id"]').val();
            var starttime = $('input[name="starttime"]').val();
            var endtime = $('input[name="endtime"]').val();
            var shu = [];

            var shu1 = new Object();
            for(var i = 0; i < tr.length; i++) {
                var datass = {};
                datass.person_name = $(tr[i]).find("input[name=person_name]").val();
                datass.person_price = $(tr[i]).find("input[name=person_price]").val();
                datass.person_num = $(tr[i]).find("input[name=person_num]").val();
                datass.minorder_num = $(tr[i]).find("input[name=minorder_num]").val();
                datass.inc_order_num = $(tr[i]).find("input[name=inc_order_num]").val();
                datass.person_id = $(tr[i]).find("input[name=person_id]").val();
                {notempty name='$standard_id'}
                datass.carType = $(tr[i]).find("select[name=carType]").val();
                {/notempty}
                datass.specs_id = specs;
                datass.time = $(tr[i]).find("input[name=minorder_num]").attr('date-rq');

                shu.push(datass);
            }
            var	dates = JSON.stringify(shu);

            layer.msg('确定提交当前选项卡的数据吗？', {
                time: 0 //不自动关闭
                ,
                btn: ['确定', '取消'],
                yes: function(index) {
                    //加载层-风格2
                    layer.load(1);
                    $.ajax({
                        url: editurl,
                        type: "post",
                        dataType: "json",
                        data: {
                            goods:goods,
                            starttime:starttime,
                            endtime:endtime,
                            dates
                        },
                        success: function(data) {
                            //调用日历控件生成元素
                            layer.closeAll('loading');
                            layer.msg(data.msg)
                        },
                        error: function(jqXHR) {
                            layer.msg(jqXHR);
                        }
                    });
                    layer.close(index);
//						layer.msg('清空成功');
                }
            });

            return false;
        })
        //弹框日期选择
        form.on('radio(time_type)', function(data) {
            if(logid!=0 && logid!=undefined){
                layer.msg("只允许修改套餐价格");
                return false;
            }else{
                var value = data.value;
                changeTimeType(value)
            }
        })
        //弹层单选按钮
        form.on('radio(radio)', function(data) {

            if(data.value == 3) {
                $('#chx').css('display', 'block')
                console.log(data.value)
            } else {

                $("input[type='checkbox']:checked").each(function() {

                })
                $('#chx').css('display', 'none')

            }

        });

        function clickOneday(_that)
        {
            var ri = _that.attr('date-ri');
            var specs = _that.attr('date-specs');

            $('.ri').removeClass('bj')
            _that.addClass('bj')
            $('#yue' + specs + ' #' + ri).siblings().hide();
            $('#yue' + specs + ' #' + ri).show();
            //点击时间弹框 取消自20190319-bywtt
            layer.msg(ri + '号', {
                time: 700
            });
        }
        //为表格添加点击事件
        $(document).on('click', '.ri', function() {
            if($(this).hasClass('show')){
                clickOneday($(this))
            }
        })


        //获取hash来切换选项卡，假设当前地址的hash为data-id对应的值
        element.on('tab(test1)', function() {
            var starttime = $('#starttime').val() //获取开始时间

            var endtime = $('#endtime').val() //获取结束时间
            var specs_id = this.getAttribute('data-id'); //获取当前选项卡的规格id

            //判断当前选项卡下的类容是否存在元素 不存在就进行请求生成
            if($('#yue' + specs_id + ' #yue').is(":empty")) {
                $.ajax({
                    url: posurl,
                    type: "post",
                    dataType: "json",
                    data: {
                        'specs_id': specs_id
                    },
                    success: function(data) {
                        //调用日历控件生成元素
                        yue(starttime, endtime, specs_id, data);
                    },
                    error: function(jqXHR) {
                        console.log(jqXHR);
                    }
                });
            }

        });
        function showSpecsData()
        {
            $('.Spec').html('') //清空容器
            var id = $('#goods_id').val() //获取当前商品的id
            var starttime = $('#starttime').val() //获取开始时间

            var endtime = $('#endtime').val() //获取结束时间
            if(starttime.length <= 0) {
                layer.msg('开始时间不能为空');
                return false;
            }
            if(endtime.length <= 0) {
                layer.msg('结束时间不能为空');
                return false;
            }

            //开始时间转化时间戳
            var k = parseInt(new Date(starttime + ' 00:00:00').getTime());
            //结束时间转化时间戳
            var j = parseInt(new Date(endtime + ' 23:59:59').getTime());
            //获取当前时间戳
            var d = parseInt(new Date().getTime());
            if(j < k) {
                layer.msg('结束时间不能小于开始时间');
                return false;
            }

            $.ajax({
                url: specsurl,
                type: "post",
                dataType: "json",
                data: {
                    id: id
                },
                success: function(s) {
                    if(s.code==-1){
                        layer.msg("请先添加套餐");
                        return false;
                    }
                    s= s.data;
                    var st = ''; //定义二级选项卡
                    var sp = ''; //定义二级选项卡类容

                    $('.content').html('')
                    $.each(s, function(i, v) {
                        var log_str = "";
                        if(personlog.hasOwnProperty(v.specs_id)){
                            $.each(personlog[v.specs_id],function(index,log){
                                log_str += '<div class="la" style="display:inline-block"><div class="layui-btn layui-bg-cyan showPersonLogPage" data-id="'+log.log_id+'">'+log.title+'</div><span class="delPersonlog" data-id="'+log.log_id+'">x</span></div>';
                            })
                        }
                        if(i == 0) {
                            st += '<li id="top' + v.specs_id + '" class="layui-this" data-id="' + v.specs_id + '">' + v.specs_name + '</li>'

                            sp += '<div class="layui-tab-item layui-show" id="yue' + v.specs_id + '">' +
                                '<ul class="tab-ul">' +
                                '<li class="tab-ul-title">' +
                                // '<div date-pid="' + v.specs_id + '" class="batch emptys">清空</div>' +
                                '<div date-pid="' + v.specs_id + '" class="batch add layui-btn  layui-btn-normal">批量增加</div>' +
                                '</li>' +
                                '<li class="tab-ul-title personlog" data-pid="'+v.specs_id+'" id="personlog'+v.specs_id+'">' +
                                log_str +'</li>' +

                                '</ul>' +
                                '<div class="layui-tab">' +
                                '<ul class="layui-tab-title" id="yue">' +
                                '</ul>' +
                                '<div class="layui-tab-content tas" id="tas' + v.specs_id + '">' +
                                '</div>' +
                                '</div>' +

                                '<div class="layui-form-item ">' +
                                '<div class="layui-input-block admins">' +
                                '</div>' +
                                '</div>' +

                                '</div>' +
                                '</div>';

                        } else {
                            st += '<li id="top' + v.specs_id + '" data-id="' + v.specs_id + '">' + v.specs_name + '</li>'

                            sp += '<div class="layui-tab-item" id="yue' + v.specs_id + '">' +
                                '<ul class="tab-ul">' +
                                '<li class="tab-ul-title">' +
                                // '<div class="batch emptys">清空</div>' +
                                '<div date-pid="' + v.specs_id + '" class="batch add layui-btn  layui-btn-normal">批量增加</div>' +
                                '</li>' +
                                '</ul>' +
                                '<li class="tab-ul-title personlog" data-pid="'+v.specs_id+'" id="personlog'+v.specs_id+'">' +
                                log_str +'</li>' +
                                '<div class="layui-tab">' +
                                '<ul class="layui-tab-title" id="yue">' +

                                '</ul>' +
                                '<div class="layui-tab-content tas" id="tas' + v.specs_id + '">' +

                                '</div>' +
                                '<div class="layui-form-item ">' +
                                '<div class="layui-input-block admins">' +
                                '</div>' +
                                '</div>' +

                                '</div>' +

                                '</div>';

                        }

                        $('.Spec').html(st)
                        $('.content').html(sp)

                    })

                    addhtm(starttime, endtime, s );
                },
                error: function(jqXHR) {
                    console.log(jqXHR);
                }
            });
        }
        //结束时间框失去焦点事件button
        $(document).on('click', '#button', function() {
            showSpecsData();
        })
        //渲染二级选项卡
        function addhtm(starttime, endtime, s ) {
            //发送post请求人群信息
            //默认请求第一次

            var specs_id = s[0].specs_id;
            $.ajax({
                url: posurl,
                type: "post",
                dataType: "json",
                data: {
                    'specs_id': specs_id
                },
                success: function(data) {
                    yue(starttime, endtime, specs_id, data );
                },
                error: function(jqXHR) {
                    console.log(jqXHR);
                }
            });
        }

        //			yue();
        //获取区间内的月份
        function yue(up, end, specs_id, person) {
            var da = getMonthAll(up, end);
            var yue = '';
            $('#tas' + specs_id).html('');
            for(var i = 0; i < da.length; i++) {
                var nian = da[i].split('-')
                if(i == 0) {
                    yue += '<li class="layui-this" lay-id="' + i + '">' + nian[0] + '年' + nian[1] + '月</li>';
                } else {
                    yue += '<li  lay-id="' + i + '">' + nian[0] + '年' + nian[1] + '月</li>';
                }
                var ta = datetime(da[i], i, person, specs_id, up, end);
                $('#tas' + specs_id).append(ta)
                //高亮第一个时间
                $(".ri:first").click()
            }
            $('#yue' + specs_id + ' #yue').html('')
            $('#yue' + specs_id + ' #yue').prepend(yue)

        }
        //查询时间维度里的所有月份
        function getMonthAll(begin, end) {
            var d1 = begin;
            var d2 = end;
            var dateArry = new Array();
            var s1 = d1.split("-");
            var s2 = d2.split("-");
            var mCount = 0;
            if(parseInt(s1[0]) < parseInt(s2[0])) {
                mCount = (parseInt(s2[0]) - parseInt(s1[0])) * 12 + parseInt(s2[1]) - parseInt(s1[1]) + 1;
            } else {
                mCount = parseInt(s2[1]) - parseInt(s1[1]) + 1;
            }
            if(mCount > 0) {
                var startM = parseInt(s1[1]);
                var startY = parseInt(s1[0]);
                for(var i = 0; i < mCount; i++) {
                    if(startM < 12) {
                        dateArry[i] = startY + "-" + (startM > 9 ? startM : "0" + startM);
                        startM += 1;
                    } else {
                        dateArry[i] = startY + "-" + (startM > 9 ? startM : "0" + startM);
                        startM = 1;
                        startY += 1;
                    }
                }
            }
            return dateArry;
        }

        //渲染日历
        function datetime(up, d, person, specs_id, kaishi, jieshu) {

            var kaishi = kaishi.split("-");
            var jieshu = jieshu.split("-");
            var up = up.split("-");
            var da = new Date(up[0], up[1], 0);
            //获取每月有多少天
            var day = da.getDate(); //获取当前月有多少天
            da.setDate(1)
            var we = da.getDay(); //获取当前月的第一天是星期几
            var a = 0;
            var str = '';
            var tr = '';
            var tab = ''; ///每一天的tab
            if(d == 0) {
                tr += '<div class="layui-tab-item layui-show">';
            } else {
                tr += '<div class="layui-tab-item">';
            }
            tr += "<div class='layui-col-md4'>"
            tr += '<table class="layui-table">' +
                '<div class="titl">' + up[0] + '年' + up[1] +'月</div>'+
                '<thead>' +
                '<tr class="week-title">' +
                '<td>星期日</td>' +
                '<td>星期一</td>' +
                '<td>星期二</td>' +
                '<td>星期三</td>' +
                '<td>星期四</td>' +
                '<td>星期五</td>' +
                '<td>星期六</td>' +
                '</tr>' +
                '</thead>' +
                '<tbody class="tian">';

            for(var i = 1; i <= day + we; i++) {

                a++

                if(i > we) {
                    //按时间段渲染日历
                    var light = '';
                    var u = i - we
                    var str_class = up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '">' + (u > 9 ? u : '0' + u);
                    var str_day = up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u);
                    if(str_day+','+specs_id in personprice){
                        light = 'light_star show';
                    }
                    if(u < kaishi[2] && up[0] == kaishi[0] && up[1] == kaishi[1] || u > jieshu[2] && up[0] == jieshu[0] && up[1] == jieshu[1]) {
                        str += '<td>' +
                            '<div class="ri-w '+light+'" date-specs="' + specs_id + '" date-ri="' + str_class + '</div>' +
                            '</td>';
                    } else {
                        str += '<td>' +
                            '<div class="ri '+light+'" date-specs="' + specs_id + '" date-ri="' + str_class + '</div>' +
                            '</td>';
                    }

                } else {
                    str += '<td></td>';
                }
                if(a == 7 || i == day + we) {
                    tr += '<tr>' + str + '</tr>'

                    str = '';
                    a = 0

                }
                if(u === undefined) {

                } else {

                    if(u < kaishi[2] && up[0] == kaishi[0] && up[1] == kaishi[1] || u > jieshu[2] && up[0] == jieshu[0] && up[1] == jieshu[1]) {

                    } else {
                        var time = up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u);

                        tab += '<div class="person_off " id="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '" style="display: none;">' +
                            '<table class="layui-table">';
                        {if(isset($standard_id) && !empty($standard_id))}
                        tab += '<thead><tr><th>名称</th><th>价格</th><th>数量</th><th>最低下单数</th><th>最小增长数</th><th>用车类型</th></tr></thead>';
                        {else}
                        tab += '<thead><tr><th>名称</th><th>价格</th><th>数量</th><th>最低下单数</th><th>最小增长数</th></tr></thead>';
                        {/if}
                        tab += '<tbody class="_person">';
                            //循环人群
                        //默认使用套餐数据填充 改用真实数据填充 2019-03-19
                        var oldperson = list[time+","+specs_id];
                        if(oldperson!==undefined && oldperson!==null){
                            person = oldperson;
                        }else if(time+','+specs_id in personprice){
                            person = personprice[time+","+specs_id];
                        }
                        for(var j = 0; j < person.length; j++) {

                            tab += '<tr  date-trd="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '" date-person="' + person[j].person_id + '" ><td><input type="hidden" name="person_id" date-aid="' + person[j].person_id + '" date-rq="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '" id="" class="layui-input" placeholder="成人价格" value="' + person[j].person_id + '" />' +
                                '<input readonly type="text" name="person_name" date-aid="' + person[j].person_id + '" date-rq="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '" id="" class="layui-input" placeholder="名称" value="' + person[j].person_name + '" /></td>' +
                                '<td><input readonly type="number" name="person_price" date-aid="' + person[j].person_id + '" date-rq="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '" id="" class="layui-input" placeholder="价格" value="' + person[j].person_price + '" /></td>' +
                                '<td><input readonly type="number" name="person_num" date-aid="' + person[j].person_id + '" date-rq="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '"  id="" class="layui-input" placeholder="数量" value="' + person[j].person_num + '" />' +
                                '<input readonly type="hidden" name="specs_id" id="" date-aid="' + person[j].person_id + '" date-rq="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '"  class="layui-input" placeholder="数量" value="' + person[j].specs_id + '" /></td>' +
                                '<td><input readonly type="number" name="minorder_num" date-aid="' + person[j].person_id + '" date-rq="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '"  id="" class="layui-input" placeholder="最低下单" value="' + person[j].minorder_num + '" /></td>' +
                                '<td><input readonly type="number" name="inc_order_num" date-aid="' + person[j].person_id + '" date-rq="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '"  id="" class="layui-input" placeholder="最小增长" value="' + person[j].inc_order_num + '" /></td>';
                            {notempty name='$standard_id'}
                            var carTypeTitle = getCarTypeTitle(person[j].carType);
                            tab += '<td><input readonly type="text" name="carType" date-aid="' + person[j].person_id + '" date-rq="' + up[0] + '-' + up[1] + '-' + (u > 9 ? u : '0' + u) + '"  id="" class="layui-input" placeholder="用车类型" value="' + carTypeTitle + '" /></td>';
                            {/notempty}
                            tab += '</tr>';
                        }
                        tab +=
                            '</tbody>' +
                            '</table>' +
                            '</div>';
                    }
                }
            }

            tr += '</tbody>' +
                '</table>' +
                '</div>' +
                '<div class="layui-col-md1">&nbsp</div>' +
                '<div class="layui-col-md7 tabto">' + tab + '</div>' +
                '</div>';
            return tr;
        }
        //初始化商品列表的规格数据
        $(document).ready(function(){
            showSpecsData();
        })

        //删除套餐设置
        $(document).on("click",".delPersonlog",function(){
            var log_id = $(this).attr("data-id");
            var that = this;
            //询问框
            layer.confirm('您确定删除该区间的所有价格？', {
                btn: ['是','否'] //按钮
            }, function(){
                delPersonLog(log_id,that);
            }, function(){

            });
        })

        function delPersonLog(log_id,that){
            $.post("/admin/goods/delPersonLog",{id:log_id},function(data){
                if(data.code==200){
                    $(that).parent().remove();
                    layer.msg("删除成功");
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                }
            },'json')
        }


        //批量添加的按钮点击事件
        $(document).on('click', '.add', function() {
            resetLogId();
            var pid = $(this).attr('date-pid')
            $.post(posurl, {
                'specs_id': pid
            }, function(da) {
                renderSelectTimeForm();
                form.render();
                renderPersonList(da)
            })
            //显示添加时间的按钮 不允许修改
            $(".addMoreTime").show();
            moreTimeList = [];
            $("#moreTimeArr").children().remove()
            //打开一个弹窗 点击保存触发事件
            layer.open({
                type: 1,
                area: ['1000px', '70%'],
                btn: ['保存', '取消'],
                content: $('#ceshi'),
                yes: function(index, layero) {
                    var pro_start_day = $('#starttime').val() //获取开始时间
                    var pro_end_day = $('#endtime').val() //获取结束时间
                    var log_start_day = $("input[name=t-starttime]").val();
                    var log_end_day = $("input[name=t-endtime]").val();
                    var pro_start_time = parseInt(new Date(pro_start_day + ' 00:00:00').getTime());
                    var log_start_time = parseInt(new Date(log_start_day + ' 00:00:00').getTime());
                    var pro_end_time = parseInt(new Date(pro_end_day + ' 23:59:59').getTime());
                    var log_end_time = parseInt(new Date(log_end_day + ' 23:59:59').getTime());
                    if(log_start_time < pro_start_time) {
                        layer.msg('时间段开始时间小于商品上架时间');
                        return false;
                    }
                    if(log_end_time > pro_end_time) {
                        layer.msg('时间段结束时间大于商品下架时间');
                        return false;
                    }
                    if(log_end_time < log_start_time) {
                        layer.msg('结束时间不能小于开始时间');
                        return false;
                    }
                    var time_type = $('input[name=time_type]:checked').val();
                    var month_value = $('input[name=month_value]:checked').val();
                    var time_value = [];
                    if(time_type==0 || time_type==3){
                        time_value = '';
                    }else if(time_type==1){
                        time_value = month_value;
                    }else{
                        var week_value = $("input[name=week]:checked");
                        if(week_value.length<1){
                            layer.msg("请选择日期类型");
                            return false;
                        }else{
                            $.each(week_value,function(i,v){
                                time_value.push($(v).val())
                            })
                            time_value = time_value.join(",");
                        }
                    }
                    //获取筛选的数据
                    var selectDays = getDaysByDates(log_start_day,log_end_day, time_type,time_value);
                    if(time_type==3){
                        selectDays = moreTimeList;
                    }
                    if(selectDays.length < 1){
                        layer.msg("您选择的时间段中没有时间被选择");
                        return false;
                    }
                    // 保存数据
                    var log_title = log_start_day+' - '+log_end_day;
                    packageLogData(log_title,pid,time_type,time_value,selectDays,index,moreTimeList);
                }
            });

        })
        //渲染新日期
        function renderNewDate(pid,selectDays)
        {
            var day = '';
            day += selectDays.join(',')

            day = day.split(',') //分割成数组
            shu = [];
            var tr = $('#yue' + pid + ' .tabto ._person tr');
            var gai = $('.batch_person tr');
            var ri = $('.ri');
            for(var n = 0; n < day.length; n++) {
                $.each(ri,function(i,v){
                    if($(v).attr('date-ri')==day[n]){
                        $(ri[i]).addClass('show').addClass('new_star');
                    }
                })
            }

            for(var i = 0; i < tr.length; i++) {
                for(var n = 0; n < day.length; n++) {
                    if($(tr[i]).attr('date-trd') == day[n]) {
                        for(var j = 0; j < gai.length; j++) {
                            if($(gai[j]).attr('date-id') === $(tr[i]).attr('date-person')) {
                                $(tr[i]).find("input[name=person_name]").val($(gai[j]).find("input[name=person_name]").val());
                                $(tr[i]).find("input[name=person_price]").val($(gai[j]).find("input[name=person_price]").val());
                                $(tr[i]).find("input[name=person_num]").val($(gai[j]).find("input[name=person_num]").val());
                                $(tr[i]).find("input[name=minorder_num]").val($(gai[j]).find("input[name=minorder_num]").val());
                                $(tr[i]).find("input[name=inc_order_num]").val($(gai[j]).find("input[name=inc_order_num]").val());
                                {notempty name='$standard_id'}
                                $(tr[i]).find("select[name=carType]").val($(gai[j]).find("select[name=carType]").val());
                                {/notempty}
                            }
                        }
                    }
                }

            }
        }
        //判断日期组装数据
        function getDaysByDates(starttime,endtime,time_type,time_value){
            var dateArry = new Array();
            var s1 = starttime.split("-");
            var s2 = endtime.split("-");
            var monthCount = 0;
            if(parseInt(s1[0]) < parseInt(s2[0])) {
                monthCount = (parseInt(s2[0]) - parseInt(s1[0])) * 12 + parseInt(s2[1]) - parseInt(s1[1]) + 1;
            } else {
                monthCount = parseInt(s2[1]) - parseInt(s1[1]) + 1;
            }

            var stime= new Date(starttime+' 00:00:00').getTime()-1000;
            var etime= new Date(endtime+' 23:59:59').getTime();
            if(monthCount > 0) {
                var startM = parseInt(s1[1]);
                var startY = parseInt(s1[0]);
                for(var i = 0; i < monthCount; i++) {
                    var da = new Date(startY, startM, 0);
                    //获取每月有多少天
                    var day = da.getDate(); //获取当前月有多少天
                    for(j = 1; j <= day; j++) {
                        var the_day = startY + "-" + (startM > 9 ? startM : "0" + startM) + "-" + (j > 9 ? j : "0" + j);
                        var curtime = new Date(startY + '-' + startM + '-' + j + ' 00:00:00');
                        var curtime = curtime.getTime();
                        if(curtime < stime || curtime > etime){
                            continue;
                        }
                        if (time_type == 0) {
                            dateArry.push(the_day);
                        } else if(time_type ==1) {
                            //单日
                            if (j % 2 == 1 && time_value == '8') {
                                dateArry.push(the_day);
                            } else if (j % 2 == 0 && time_value == '9') {
                                //双日
                                dateArry.push(the_day);
                            }
                        }else if(time_type ==2){
                            //周
                            var value = time_value.split(",");
                            var w = new Date(startY + '-' + startM + '-' + j)
                            var the_week = w.getDay();
                            var index= value.indexOf(String(the_week));
                            if ( index > -1) {
                                dateArry.push(the_day);
                            }

                        }
                    }
                    if(startM<12){
                        startM += 1;
                    }else{
                        startM = 1;
                        startY += 1;
                    }
                }
            }
            return dateArry;
        }
        //组装数据
        function packageLogData(time,spec_id,time_type,time_value,date,index,more_time){
            //记录数据
            var log = {};
            var mydata = null;
            //组装person列表
            var specs = [];
            var personlist = $(".batch_person tr");
            $.each(personlist,function(i,v){
                var spec = {};
                spec.person_id = $(v).find("input[name=person_id]").val();
                spec.person_price = $(v).find("input[name=person_price]").val();
                spec.carType = $(v).find("select[name=carType]").val();
                specs.push(spec);
            })
            log.log_id = logid;
            log.specs = specs;
            log.date = date;
            //组装时间集合
            log.spec_id = spec_id;
            log.time = time;
            log.time_type = time_type;
            log.time_value = time_value;
            log.more_time = more_time;
            var param = JSON.stringify(log);
            var shadowindex = layer.load(1); //添加laoding,0-2两种方式
            $.post("/admin/goods/personlog",{param},function(data){
                layer.close(shadowindex);
                layer.msg(data.msg);
                if(data.code==200){
                    setTimeout(function(){
                        window.location.reload();
                    },1500)
                    // resetLogId()
                    // if(data.data.is_add){
                    //     var str = "";
                    //     str += '<div class="la" style="display:inline-block"><div class="layui-btn layui-bg-cyan showPersonLogPage" data-id="'+data.data.id+'">'+time+'</div><span class="delPersonlog" data-id="'+data.data.id+'">x</span></div>';
                    //     $("#personlog"+spec_id).append(str);
                    // }
                    // getPersondayLog();
                    // renderNewDate(spec_id,date)
                    // layer.close(index);
                }
            },'json')
            return mydata;
        }
        //回复操作状态
        $(document).on('click','.showPersonLogPage',function(){
            var id = $(this).attr('data-id');
            var pid = $($(this).parent().parent()).attr("data-pid");
            var log_data = personlog[pid];
            var log = {};
            $.each(log_data,function(i,v){
                if(v.log_id==id){
                    log = v;
                    return false;
                }
            })
            logid = log.log_id;
            renderSelectTimeForm();
            form.render();
            renderPersonList(log.person_json);
            renderTimeInfo(log);
            changePersonTimeSelectStatus();
            //打开一个弹窗 点击保存触发事件
            layer.open({
                type: 1,
                area: ['1000px', '70%'],
                btn: ['保存', '取消'],
                content: $('#ceshi'),
                yes: function(index, layero) {
                    var pro_start_day = $('#starttime').val() //获取开始时间
                    var pro_end_day = $('#endtime').val() //获取结束时间
                    var log_start_day = $("input[name=t-starttime]").val();
                    var log_end_day = $("input[name=t-endtime]").val();
                    var pro_start_time = parseInt(new Date(pro_start_day + ' 00:00:00').getTime());
                    var log_start_time = parseInt(new Date(log_start_day + ' 00:00:00').getTime());
                    var pro_end_time = parseInt(new Date(pro_end_day + ' 23:59:59').getTime());
                    var log_end_time = parseInt(new Date(log_end_day + ' 23:59:59').getTime());
                    if(log_start_time < pro_start_time) {
                        layer.msg('时间段开始时间小于商品上架时间');
                        return false;
                    }
                    if(log_end_time > pro_end_time) {
                        layer.msg('时间段结束时间大于商品下架时间');
                        return false;
                    }
                    if(log_end_time < log_start_time) {
                        layer.msg('结束时间不能小于开始时间');
                        return false;
                    }
                    var time_type = $('input[name=time_type]:checked').val();
                    var month_value = $('input[name=month_value]:checked').val();
                    var time_value = [];
                    if(time_type==0 || time_type==3){
                        time_value = '';
                    }else if(time_type==1){
                        time_value = month_value;
                    }else{
                        var week_value = $("input[name=week]:checked");
                        if(week_value.length<1){
                            layer.msg("请选择日期类型");
                            return false;
                        }else{
                            $.each(week_value,function(i,v){
                                time_value.push($(v).val())
                            })
                            time_value = time_value.join(",");
                        }
                    }
                    //获取筛选的数据
                    var selectDays = getDaysByDates(log_start_day,log_end_day, time_type,time_value);
                    if(time_type==3){
                        selectDays = moreTimeList;
                    }
                    if(selectDays.length < 1){
                        layer.msg("您选择的时间段中没有时间被选择");
                        return false;
                    }
                    // 保存数据
                    var log_title = log_start_day+' - '+log_end_day;
                    packageLogData(log_title,pid,time_type,time_value,selectDays,index,moreTimeList);
                },
                cancel:function(index){
                    moreTimeList = [];
                }
            });

        })

        //渲染personlist
        function renderPersonList(personList)
        {
            //渲染人群
            $('.batch_person').html('');
            var sr = '';
            $.each(personList, function(i, v) {
                sr += '<tr date-id="' + v.person_id + '">' +
                    '<td><input readonly type="text" name="person_name" id="person_name" class="layui-input" placeholder="' + v.person_name + '" value="' + v.person_name + '"/>' +
                    '<input type="hidden" name="person_id" id="person_id" class="layui-input" placeholder="' + v.person_id + '" value="' + v.person_id + '"/></td>' +
                    '<td><input type="text" name="person_price" id="person_price" class="layui-input" placeholder="' + v.person_name + '价格" value="' + v.person_price + '"/></td>' +
                    '<td><input readonly type="text" name="person_num" id="person_num" class="layui-input" placeholder="数量" value="' + v.person_num + '" /></td>' +
                    '<td><input readonly type="text" name="minorder_num" id="minorder_num" class="layui-input" placeholder="最低下单" value="' + v.minorder_num +'" /></td>' +
                    '<td><input readonly type="text" name="inc_order_num" id="inc_order_num" class="layui-input" placeholder="最小增长" value="' + v.inc_order_num +'" /></td>';
                {notempty name='$standard_id'}
                var carTypeList = getCarTypeList();
                sr += '<td><select name="carType" id="" value="'+ v.carType +'">'+carTypeList+'</select></td>';
                {/notempty}
                sr += '</tr>';
            })

            $('.batch_person').html(sr);
            var selectCarType = $('.batch_person').find("select[name=carType]");
            $.each(selectCarType,function(i,v){
                console.log($(v).attr("value"));
                $(v).val($(v).attr("value"))
            })
            form.render('select');

        }

        //渲染时间
        function renderTimeInfo(log){
            var time = log.title.split(" - ");
            $("input[name=t-starttime]").val(time[0]);
            $("input[name=t-endtime]").val(time[1]);
            var time_type = log.time_type;
            var time_value = log.time_value;
            var date_arr = JSON.parse(log.date_json);
            var more_time_arr = JSON.parse(log.more_time) || [];
            moreTimeList = more_time_arr;
            // $("input[name=time_type]").removeAttr("checked");
            if(time_type==0){
                $("input[name=time_type]:nth-child(1)").attr("checked","checked");
            }else if(time_type== 1){
                $("input[name=time_type]:nth-child(3)").attr("checked","checked");
                if(time_value=='8'){
                    $("input[name=month_value]:nth-child(1)").attr("checked","checked");
                }else{
                    $("input[name=month_value]:nth-child(3)").attr("checked","checked");
                }
                if(more_time_arr.length>0){
                    $("#moreTimeArr").children().remove();
                    var more_time_str = "";
                    $.each(more_time_arr,function(i,v){
                        more_time_str += '<a class="layui-btn layui-btn-sm layui-bg-cyan" data-id="'+v+'" style="margin:8px;">'+v+'</a>\n';
                    })
                    $("#moreTimeArr").append(more_time_str);
                }
            }else if(time_type==2){
                $("input[name=time_type]:nth-child(5)").attr("checked","checked");
                var time_value_arr = time_value.split(",");
                for(var i=0;i<7;i++){
                    if(time_value.indexOf(String(i)) > -1){
                        if(i==0){
                            $("input[name=week]:nth-child(13)").attr("checked","checked");
                        }else{
                            $("input[name=week]:nth-child("+(2*i-1)+")").attr("checked","checked");
                        }
                    }
                }
                if(more_time_arr.length>0){
                    $("#moreTimeArr").children().remove();
                    var more_time_str = "";
                    $.each(more_time_arr,function(i,v){
                        more_time_str += '<a class="layui-btn layui-btn-sm layui-bg-cyan" data-id="'+v+'" style="margin:8px;">'+v+'</a>\n';
                    })
                    $("#moreTimeArr").append(more_time_str);
                }
            }else if(time_type==3){
                $("input[name=time_type]:nth-child(7)").attr("checked","checked");
                if(date_arr.length>0){
                    $("#moreTimeArr").children().remove();
                    var date_str = "";
                    $.each(date_arr,function(i,v){
                        date_str += '<a class="layui-btn layui-btn-sm layui-bg-cyan" data-id="'+v+'" style="margin:8px;">'+v+'</a>\n';
                    })
                    $("#moreTimeArr").append(date_str);
                }
            }
            //隐藏添加时间的按钮 不允许修改
            $(".addMoreTime").hide();
            changeTimeType(time_type);
        }

        //切换状态 修改和新增的区别
        function changePersonTimeSelectStatus()
        {
            if(logid==0 || logid==undefined){
                $("input[name=t-starttime]").prop("disabled",false);
                $("input[name=t-endtime]").prop("disabled",false);
                $("#ceshi").find("input[type=radio]").prop("disabled",false)
                $("#ceshi").find("input[type=checkbox]").prop("disabled",false)
            }else{
                $("input[name=t-starttime]").prop("disabled",true);
                $("input[name=t-endtime]").prop("disabled",true);
                $("#ceshi").find("input[type=radio]").prop("disabled",true)
                $("#ceshi").find("input[type=checkbox]").prop("disabled",true)
            }
            form.render();
        }

        //还原logid
        function resetLogId()
        {
            logid = 0;
            changePersonTimeSelectStatus()
        }

        function renderSelectTimeForm()
        {
            $('#selectTimeForm').children().remove();
            var str = '<label class="layui-form-label">&nbsp;</label>\n' +
                '                        <div class="layui-input-block layui-col-xs6" style="margin: 0;">\n' +
                '                            <input type="radio" lay-filter="time_type" title="全部" name="time_type" value="0" />\n' +
                '                            <input type="radio" lay-filter="time_type" title="按单双日" name="time_type" value="1" />\n' +
                '                            <input type="radio" lay-filter="time_type" title="按星期" name="time_type" value="2" />\n' +
                '                            <input type="radio" lay-filter="time_type" title="按天" name="time_type" value="3" />\n' +
                '                        </div>\n' +
                '                        <div class="layui-input-block layui-col-xs8" id="single" style="margin: 0;display: none;">\n' +
                '                            <input type="radio" lay-filter="month_value" title="每月单日" name="month_value" value="8" />\n' +
                '                            <input type="radio" lay-filter="month_value" title="每月双日" name="month_value" value="9" />\n' +
                '                        </div>\n' +
                '                        <div class="layui-input-block layui-col-xs8" id="week" style="margin: 0;display: none;">\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周一" class="time_week" name="week" value="1" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周二" class="time_week" name="week" value="2" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周三" class="time_week" name="week" value="3" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周四" class="time_week" name="week" value="4" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周五" class="time_week" name="week" value="5" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周六" class="time_week" name="week" value="6" />\n' +
                '                            <input type="checkbox" lay-skin="primary" lay-filter="xq" title="每周日" class="time_week" name="week" value="0" />\n' +
                '                        </div>\n';
            //增加额外的时间
            $('#selectTimeForm').append(str);
        }

        //获取拼车类型
        function getCarTypeList()
        {
            var str = "";
            var carTypeArray = {$carTypeList};
            str += '<option value="0">请选择</option>';
            $.each(carTypeArray,function(i,v){
                str += '<option value="'+v.cartype_id+'">'+v.title+'</option>';
            })
            return str;
        }

        //获取拼车类型名称
        function getCarTypeTitle(carType)
        {
            var title = "";
            switch (carType) {
                case 1:
                    title = "5座";
                    break;
                case 10:
                    title = "7座";
                    break;
                case 15:
                    title = "8座";
                    break;
                case 20:
                    title = "12座";
                    break;
                case 30:
                    title = "15座";
                    break;
                default:
                    title = "";
                    break;
            }
            return title;
        }
    });

        $(".addMoreTime").click(function(){
            var currentTime = $("input[name=moreTime]").val();
            console.log(currentTime);
            var t_starttime=$("input[name=t-starttime]").val();
            var t_endtime=$("input[name=t-endtime]").val();
            if(t_starttime=='' || t_endtime==''){
                layer.msg("请选择开始和结束时间");return false;
            }else if(currentTime=="" || currentTime==undefined){
                layer.msg("请选择时间");
            }else if($.inArray(currentTime,moreTimeList)>-1){
                layer.msg("请勿重复添加时间");
            }else if(currentTime<t_starttime || currentTime > t_endtime){
                layer.msg("请在开始和结束时间之间选择");
            }else{
                moreTimeList.push(currentTime);
                var str = '<a class="layui-btn layui-btn-sm layui-bg-cyan delMoreTime" data-id="'+currentTime+'" style="margin:8px;">'+currentTime+' <i class="layui-icon">&#x1006;</i></a>\n';
                $("#moreTimeArr").append(str);
            }
        })
        $(document).on('click','.delMoreTime',function(){
            console.log(moreTimeList);
            var currentTime = $(this).attr('data-id');
            moreTimeList.splice($.inArray(currentTime,moreTimeList),1);
            $(this).remove();
        })
</script>
<script type="text/javascript">
    layui.use('layer', function(){
        var layer = layui.layer;
        $('.a_menu').click(function(){
            var url = $(this).attr('href');
            var a = 0;
            $.ajax({
                url:url
                ,async:false
                ,success:function(res){
                    if(res.code == 0) {
                        layer.msg(res.msg);
                        a = 1;
                    }
                }
            })
            if(a === 0) {
                layer.open({
                    type:2,
                    content:url,
                    area: ['800px', '680px'],
                    end:function(){
                        location.reload();
                    }
                });
            }
            return false;
        })

    });

</script>

</html>